package part01_七大原则.p02_接口隔离原则;

/**
 * @ClassName: Segregation01
 * @Author: AllenSun
 * @Date: 2019/12/2 22:11
 */
public class Segregation01 {
    public static void main(String[] args) {

    }
}

interface Interface01{
    //类A和类C需要的方法不一样，但是都在这个接口里，所以没有实现接口隔离原则
    void operation01();
    void operation02();
    void operation03();
    void operation04();
    void operation05();

}

class B implements Interface01{

    @Override
    public void operation01() {
        System.out.println("B 实现了operation01");
    }

    @Override
    public void operation02() {
        System.out.println("B 实现了operation02");
    }

    @Override
    public void operation03() {
        System.out.println("B 实现了operation03");
    }

    @Override
    public void operation04() {
        System.out.println("B 实现了operation04");
    }

    @Override
    public void operation05() {
        System.out.println("B 实现了operation05");
    }
}

class D implements Interface01{

    @Override
    public void operation01() {
        System.out.println("D 实现了operation01");
    }

    @Override
    public void operation02() {
        System.out.println("D 实现了operation02");
    }

    @Override
    public void operation03() {
        System.out.println("D 实现了operation03");
    }

    @Override
    public void operation04() {
        System.out.println("D 实现了operation04");
    }

    @Override
    public void operation05() {
        System.out.println("D 实现了operation05");
    }
}

//类A通过接口Interface01依赖类B
//但是Interface01对于类A来说不是最小接口，它还实现了一些自己不需要的方法
class A{
    public void depend01(Interface01 i){
        i.operation01();
    }

    public void depend02(Interface01 i){
        i.operation02();
    }

    public void depend03(Interface01 i){
        i.operation03();
    }


}

// 类C通过接口Interface01依赖类D
//但是Interface01对于类A来说不是最小接口，它还实现了一些自己不需要的方法
class C{
    public void depend01(Interface01 i){
        i.operation01();
    }

    public void depend04(Interface01 i){
        i.operation04();
    }

    public void depend05(Interface01 i){
        i.operation05();
    }
}